<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
 </head>
 <body>
   <input type="text" id="text"> <br>
   <input type="button" value="开始" id="start">
   <input type="button" value="结束" id="stop">
 </body>
 <script>
    var text = document.getElementById("text");
	var start = document.getElementById("start");
	var stop = document.getElementById("stop");
    var i = 0;
	var s;
	start.addEventListener("click",function(){
	    show();
	})
    stop.addEventListener("click",function(){
	  clearTimeout(s);
	})
	function show(){
	   text.value = i;
	   i++;
	   s=setTimeout(show,1000);
	}
 </script>
</html>
